package com.weixin.message.common;

import com.weixin.message.common.message.WeixinResponse;
import com.weixin.message.common.message.req.ImageMessage;
import com.weixin.message.common.message.req.LinkMessage;
import com.weixin.message.common.message.req.LocationMessage;
import com.weixin.message.common.message.req.TextMessage;
import com.weixin.message.common.message.req.VoiceMessage;
import com.weixin.message.common.message.req.event.EventMessage;
import com.weixin.message.common.service.AbstractEventMessageService;
import com.weixin.message.common.service.AbstractImageMessageService;
import com.weixin.message.common.service.AbstractLinkMessageService;
import com.weixin.message.common.service.AbstractLocationMessageService;
import com.weixin.message.common.service.AbstractTextMessageService;
import com.weixin.message.common.service.AbstractVoiceMessageService;

/**
 * 消息处理扩展类,可以用spring注入方式注入对应的处理类
 */
public abstract class MessageServiceDispatcher extends WeixinMessageProcessor {

	private AbstractEventMessageService eventMessageService;
	private AbstractImageMessageService imageMessageService;
	private AbstractLinkMessageService linkMessageService;
	private AbstractLocationMessageService locationMessageService;
	private AbstractTextMessageService textMessageService;
	private AbstractVoiceMessageService voiceMessageService;

	@Override
	protected WeixinResponse onText(TextMessage message) {
		return textMessageService.doService(message);
	}

	@Override
	protected WeixinResponse onImage(ImageMessage message) {
		return imageMessageService.doService(message);
	}

	@Override
	protected WeixinResponse onLink(LinkMessage message) {
		return linkMessageService.doService(message);
	}

	@Override
	protected WeixinResponse onLocation(LocationMessage message) {
		return locationMessageService.doService(message);
	}

	@Override
	protected WeixinResponse onVoice(VoiceMessage message) {
		return voiceMessageService.doService(message);
	}

	@Override
	protected WeixinResponse onEvent(EventMessage message) {
		return eventMessageService.doService(message);
	}

	public void setEventMessageService(AbstractEventMessageService eventMessageService) {
		this.eventMessageService = eventMessageService;
	}

	public void setImageMessageService(AbstractImageMessageService imageMessageService) {
		this.imageMessageService = imageMessageService;
	}

	public void setLinkMessageService(AbstractLinkMessageService linkMessageService) {
		this.linkMessageService = linkMessageService;
	}

	public void setLocationMessageService(AbstractLocationMessageService locationMessageService) {
		this.locationMessageService = locationMessageService;
	}

	public void setTextMessageService(AbstractTextMessageService textMessageService) {
		this.textMessageService = textMessageService;
	}

	public void setVoiceMessageService(AbstractVoiceMessageService voiceMessageService) {
		this.voiceMessageService = voiceMessageService;
	}

}
